@isTest
private class WeiXinRepairControllerTest {
    static testMethod void testMethod1() {
        // Id ldcProfile = [Select Id From Profile Where Name ='系统管理员' or Name='System Administrator'].Id;
        Id ldcProfile = [Select Id From Profile Where Name ='迈克经销商' ].Id;

    	 User u1 = new User( Alias = 'samLdc1', 
                         Email = 'ldc@test.com.maike',
                         Emailencodingkey = 'UTF-8', 
                         Lastname = '用户1', 
                         Languagelocalekey = 'en_US',
                         Localesidkey = 'en_US', 
                         Profileid = ldcProfile, 
                         Country = 'United States',
                         CompanyName = 'Y-MKSY',
                         IsActive = true,
                         FederationIdentifier = '123451',
                         SubCompany__c='四川省迈克实业有限公司',
                         UserDepartment__c='客户服务中心(工程部)',
                         Timezonesidkey = 'America/Los_Angeles', 
                         EmployeeNumber = '123451',
                         Username = 'Matldc1@test.com.maike',
                         ResponseCode__c = 'TTTT' );
    	 insert u1;
		System.debug(u1);
    	
 /*System.runAs(u) {
        a.PersonEmail = 'test@madeupaddress.com';
        update a;
    }*/


        ResponsibleServer__c rs = new ResponsibleServer__c();
    	rs.ResponseCode__c = 'TTTT';
    	 rs.PriorityUser__c = u1.Id;

    	rs.WorkOnTime__c = Time.newInstance(9, 0, 0, 0);
    	rs.WorkOffTime__c = Time.newInstance(17,30, 0, 0);
    	rs.VacationStartDate__c = Date.newInstance(System.now().year(), System.now().month(), System.now().day() );
    	rs.VacationEndDate__c = Date.newInstance(System.now().year(), System.now().month(), System.now().day() );

    	rs.subCompany__c = 'MKSY';
    	rs.ServiceType__c = '分销服务';

    	insert rs;

        Product__c p = TestUtils.createInst();
        p.Category0__c ='仪器';
        p.Model__c = 'i 3000';
        insert p ; 

    	Account acc = TestUtils.createAccount();
        insert acc;

        Equipment__c eq = new Equipment__c();
        eq.ServiceAccount__c = rs.Id;
        eq.Account__c = acc.Id;
        eq.IMEINumber__c = '12345xx';
        eq.Product__c = p.Id;
        insert eq;

        Case ca = new Case();
        ca.AccountId = acc.Id;
        ca.Origin = '扫码报修';
        ca.ServiceManufacture__c = eq.Id;
        ca.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('ServiceOrder', 'Case');
        insert ca;




        PageReference page = new PageReference('/apex/WeiXinRepair');
        System.Test.setCurrentPage(page);


        WeiXinRepairController wx=new WeiXinRepairController();
        wx.init();


        wx.newcase = ca.Id;
        wx.newCase();
        wx.newcase = ca.Id;
        wx.remove();

    }
}